import pyodbc

#备用站
server = "114.115.220.137,1688"    # 连接服务器地址
user = "zhukabao"               # 连接帐号
password = "Wang@Dong@jj88Prd"           # 连接密码
db = "juanjuan"

def GetConnect():
    conn_info = 'DRIVER={SQL Server};DATABASE=%s;SERVER=%s;UID=%s;PWD=%s' % (db, server, user, password)
    conn = pyodbc.connect(conn_info)
    cur = conn.cursor()
    if not cur:
        raise(NameError,'数据库连接失败')
    else:
        print("数据库连接成功")

        cur.execute(f"SELECT id from Hotels WHERE ID = 17040")
        row = cur.fetchone()
        if row:
            return row[0]
        else:
            return ('没有找到任何值，请排查')

if __name__ == '__main__':
    GetConnect()